﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BUS;
using DTO;

namespace GUI
{
    public partial class ChiTietPhieuCom : Form
    {
        public ChiTietPhieuCom()
        {
            InitializeComponent();
        }
        private int _ID_PhieuDatCom;

        public int ID_PhieuDatCom
        {
            get { return _ID_PhieuDatCom; }
            set { _ID_PhieuDatCom = value; }
        }
        public void LoadChiTietPC(int ma)
        {
            ChiTietPhieuComBUS ctpcBUS = new ChiTietPhieuComBUS();
            List<MonAnDTO> listMA = new List<MonAnDTO>();
            List<ChiTietPhieuComDTO> listCTPC = new List<ChiTietPhieuComDTO>();
            try
            {
                listCTPC = ctpcBUS.LayDanhSachCPPCTheoMa(ma);
                this.dgvchitietpc.Rows.Clear();

                for (int i = 0; i < listCTPC.Count; i++)
                {
                    ChiTietPhieuComDTO ctpcDTO = new ChiTietPhieuComDTO();
                    MonAnBUS maBUS = new MonAnBUS();
                    MonAnDTO maDTO = new MonAnDTO();

                    ctpcDTO = listCTPC[i];

                    //listMA = maBUS.LayDanhSachMonAnTheoMa(ctpcDTO.ID_MonAn);
                    //maDTO = listMA[0];

                    String ID_MonAn = ctpcDTO.ID_MonAn.ToString();
                    String TenMonAn = maDTO.TenMonAn;
                    String SoLuong = ctpcDTO.SoLuong.ToString();
                    String Gia = ctpcDTO.Gia.ToString();
                    dgvchitietpc.Rows.Add(ID_MonAn, SoLuong, Gia);

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi dữ liệu");
                MessageBox.Show(ex.ToString());
            }
        }

        private void ChiTietPhieuCom_Load(object sender, EventArgs e)
        {
            LoadChiTietPC(_ID_PhieuDatCom);
        }
    }
}
